from cake import models
from rest_framework import serializers
class CateSerializer(serializers.ModelSerializer):
    class Meta:
        model = models.CateCakeModel
        fields = "__all__"
class TasteSerializer(serializers.ModelSerializer):
    class Meta:
        model = models.TasteCakeModel
        fields = "__all__"
class CakeSerializer(serializers.ModelSerializer):
    cate_name = serializers.SerializerMethodField(read_only=True)
    taste_name = serializers.SerializerMethodField(read_only=True)
    def get_cate_name(self,obj):
        return obj.cate.cname
    def get_taste_name(self,obj):
        return obj.taste.tname
    class Meta:
        model = models.CakesModel
        fields = "__all__"
class BannerSerializer(serializers.ModelSerializer):
   class Meta:
        model = models.BannerModel
        fields = "__all__"


